//
//  AddCaseViewController.m
//  e律师
//
//  Created by 韦淋 on 2017/5/18.
//  Copyright © 2017年 test. All rights reserved.
//

#import "AddCaseViewController.h"


//#import "CustomDayDatePicker.h"
//#import "FTT_PickerView.h"

@interface AddCaseViewController ()<JHPickerDelegate>


@property (nonatomic, strong) NSArray *ajlxArr;
@property (nonatomic, strong) NSArray *ajflArr;
@property (nonatomic, assign) NSInteger seletTag;
@property (nonatomic, assign) NSInteger ajlxIndex;
@property (nonatomic, assign) NSInteger ajflIndex;
@property (nonatomic, strong) NSString *selectedAJLX;
//@property (nonatomic, strong) NSString *selectedAJFL;
@end

@implementation AddCaseViewController
- (void)viewWillAppear:(BOOL)animated{
    self.tabBarController.tabBar.hidden = YES;
    //    self.automaticallyAdjustsScrollViewInsets = false;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.barTitleLable.text = @"新增案件 ";
    self.ajlxIndex = 400;
    self.ajflIndex = 400;
    self.view.backgroundColor = [UIColor whiteColor];
    [self initUI];
}
- (void)initUI{
    UILabel *titleLable = [[UILabel alloc] initWithFrame:CGRectMake(10, 80, SCREEN_WIDTH - 20, 50)];

    titleLable.backgroundColor = [UIColor colorWithRed:33.0f/255.0f green:180.0f/255.0f blue:237.0f/255.0f alpha:1.0f];
    titleLable.text = @"请选择案件类型";
    titleLable.layer.cornerRadius = 5;
    titleLable.layer.masksToBounds = YES;
    titleLable.textAlignment = NSTextAlignmentCenter;
    titleLable.textColor = [UIColor whiteColor];
    //    [headerlablew setFont:15];
    
    for (int i = 0; i < 2; i ++) {
        
        
        UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(20, 150 + i * 80, SCREEN_WIDTH - 40, 50)];
        lable.layer.masksToBounds = YES;
        lable.layer.borderWidth = 0.5f;
        lable.layer.cornerRadius = 5;
        lable.textAlignment = NSTextAlignmentCenter;
        lable.text = @"请选择";
        lable.layer.borderColor = [UIColor colorWithRed:33.0f/255.0f green:180.0f/255.0f blue:237.0f/255.0f alpha:1.0f].CGColor;
        lable.tag = 1000 + i;
        
        UIButton *button_lable = [[UIButton alloc] initWithFrame:CGRectMake(20, 150 + i * 80, SCREEN_WIDTH - 40, 50)];
        button_lable.tag = 1000 + i;
        [button_lable addTarget:self action:@selector(lableDidClick:) forControlEvents:(UIControlEventTouchUpInside)];
        
        [self.view addSubview:lable];
        [self.view addSubview:button_lable];
    }
    
    UIButton *submitButton = [[UIButton alloc] initWithFrame:CGRectMake(10, 300, SCREEN_WIDTH - 20, 50)];
    submitButton.backgroundColor = [UIColor colorWithRed:33.0f/255.0f green:180.0f/255.0f blue:237.0f/255.0f alpha:1.0f];
    [submitButton setTitle:@"确认提交" forState:UIControlStateNormal];
    submitButton.titleLabel.textAlignment = NSTextAlignmentCenter;
    submitButton.titleLabel.textColor = [UIColor whiteColor];
    submitButton.layer.cornerRadius = 5;
    submitButton.layer.masksToBounds = YES;
    [submitButton addTarget:self  action:@selector(action_Submit:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:submitButton];
    
    [self.view addSubview:titleLable];
}
#pragma nark - buttonTarget
- (void)lableDidClick:(UIButton *)sender{
    if (sender.tag == 1000) {
        self.seletTag = 1000;
        JHPickView *picker = [[JHPickView alloc]initWithFrame:self.view.bounds];
        picker.delegate = self ;
        picker.selectLb.text = @"请选择";
        picker.customArr = self.ajlxArr;
        [self.view addSubview:picker];
    }
    if (sender.tag == 1001) {
        if (self.ajlxIndex == 400) {
            [MBProgressHUD showError:@"请选择案件类型"];
            [MBProgressHUD hideHUDForView:self.view animated:YES];
        }else{
            self.seletTag = 1001;
            JHPickView *picker = [[JHPickView alloc] initWithFrame:self.view.bounds];
            picker.delegate = self ;
            picker.selectLb.text = @"请选择";
            picker.customArr = self.ajflArr[self.ajlxIndex];
            [self.view addSubview:picker];
        }
    }
}
#pragma mark - JHPickerViewDelegate
-(void)PickerSelectorIndixString:(NSString *)str
{
    if (self.seletTag == 1000) {
        UILabel *lable = [self.view viewWithTag:1000];
        lable.text = str;
        self.selectedAJLX = str;
        self.ajlxIndex = [self.ajlxArr indexOfObject:str];
        UILabel *lable2 = [self.view viewWithTag:1001];
        lable2.text = self.ajflArr[self.ajlxIndex][0];
        self.ajflIndex = [self.ajflArr[self.ajlxIndex] indexOfObject:lable2.text];
    }
    if (self.seletTag == 1001) {
        UILabel *lable = [self.view viewWithTag:1001];
        lable.text = str;
//        self.selectedAJFL = str;
        self.ajflIndex = [self.ajflArr[self.ajlxIndex] indexOfObject:str];
    }
    
}


#pragma mark - ButtontTarget
- (void)action_Submit:(UIButton *)sender{
    NSLog(@"确认提交" );
    NSLog(@"ajlx = %ld   ajfl = %ld",self.ajlxIndex,self.ajflIndex);
    if (self.ajlxIndex == 400 && self.ajflIndex == 400) {
        NSLog(@"请选择");
        [MBProgressHUD showError:@"请选择案件类型"];
        [MBProgressHUD hideHUDForView:self.view animated:YES];
    }
    else{
        
        
        AddCaseInfoViewController *ACVC = [[AddCaseInfoViewController alloc] init];
        ACVC.ajlxStr = self.selectedAJLX;
//        ACVC.ajflStr = self.selectedAJFL;
        ACVC.flag = self.ajlxIndex + 1;
        ACVC.ajlx = self.ajlxIndex + 1;
        ACVC.ajfl = self.ajflIndex + 1;
        [self.navigationController pushViewController:ACVC animated:YES];
//       [MBProgressHUD showHUDAddedTo:self.view animated:YES];
//
//       
    }
    
}
#pragma mark - Getter
- (NSArray *)ajlxArr{
    if (!_ajlxArr) {
//        _ajlxArr = [NSArray arrayWithObjects:@"民事案件",@"刑事案件",@"行政案件",@"非诉讼法律事物",@"法律顾问",@"执行案件",@"中保案件",@"仲裁案件",@"破产案件",@"咨询代写律师", nil];
        _ajlxArr = [NSArray arrayWithObjects:@"民事案件",@"刑事案件",@"行政案件",@"非诉讼法律事物",@"法律顾问",@"执行案件",@"中保案件",@"仲裁案件",@"破产案件", nil];
    }
    return _ajlxArr;
}
- (NSArray *)ajflArr{
    if (!_ajflArr) {
        _ajflArr = [NSArray arrayWithObjects:
                                @[@"合同纠纷案",@"侵权纠纷案",@"婚姻家庭纠纷案",@"继承纠纷案",@"劳动纠纷案",@"涉及农民工案件",@"涉及未成年人案件",@"知识产权案件",@"交通事故纠纷",@"物权纠纷",@"涉外与海事海商纠纷",@"医疗事故纠纷",@"环境保护纠纷",@"不正当竞争、垄断纠纷",@"无因管理、不当得利纠纷",@"人格权纠纷",@"国家赔偿案件",@"民商事执行案件",@"其他"],
                                               
                                @[@"公诉案件辩护",@"自诉案件辩护",@"提供咨询、代为申诉、控告",@"申请取保候审",@"死刑案件辩护",@"被告人委托辩护",@"法律援助辩护",@"公诉案件附带民事诉讼代理",@"自诉案件代理",@"其他"],
                                               
                                @[@"代理原告",@"代理被告",@"代理第三人",@"其他"],
                                               
                                @[@"知识产权",@"房地产",@"公司业务",@"金融",@"证券",@"期货",@"税务代理",@"重大建设项目合计",@"国家赔偿纠纷",@"其他"],
                                               
                                @[@"政府法律顾问",@"企业法律顾问",@"事业单位法律顾问",@"社会团体法律顾问",@"公民个人法律顾问",@"其他"],
                                               
                                @[@"合同纠纷案",@"侵权纠纷案",@"婚姻家庭纠纷案",@"继承纠纷案",@"劳动纠纷案",@"涉及农民工案件",@"涉及未成年人案件",@"知识产权案件",@"交通事故纠纷",@"物权纠纷",@"涉外与海事海商纠纷",@"医疗事故纠纷",@"环境保护纠纷",@"不正当竞争、垄断纠纷",@"无因管理、不当得利纠纷",@"人格权纠纷",@"国家赔偿案件",@"民商事执行案件",@"其他"],
                                               
                                @[@"合同纠纷案",@"侵权纠纷案",@"婚姻家庭纠纷案",@"继承纠纷案",@"劳动纠纷案",@"涉及农民工案件",@"涉及未成年人案件",@"知识产权案件",@"交通事故纠纷",@"物权纠纷",@"涉外与海事海商纠纷",@"医疗事故纠纷",@"环境保护纠纷",@"不正当竞争、垄断纠纷",@"无因管理、不当得利纠纷",@"人格权纠纷",@"国家赔偿案件",@"民商事执行案件",@"其他"],
                                                                            
                                @[@"国内仲裁",@"劳动争议仲裁",@"涉外仲裁"],
                                                                            
                                @[@"破产管理人",@"债权人代理人",@"政府委托人",@"破产和解",@"破产重整",@"破产清算",@"其他代理人"], nil];
        
//                                @[@"口头法律咨询（人次）",@"书面法律咨询（人次）",@"代写法律文书（件）"], nil];
    }
    return _ajflArr;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
